package com.aistar.mapper;

import com.aistar.model.entity.Employer;
import com.aistar.model.entity.User;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @ClassName: EmployerMapper
 * @author: 孙炳迅
 * @date: 2021/9/27 20:35
 * @Description: TODO...
 */
public interface EmployerMapper {

    // 根据招聘者id获取招聘者所在的公司id
    @Select("select company_id from employer where id = #{id}")
    Integer findCompanyIdById(Integer id);

    // 根据用户id查询招聘者实体
    @Select("select id,name,avatar_img,status,user_id,company_id from employer where user_id = #{userId}")
    Employer findByUserId(Integer userId);

    // 根据id查询招聘者实体
    @Select("select id,name,avatar_img,status,user_id,company_id from employer where id = #{id}")
    Employer findById(Integer id);

    // 根据id修改用户的名称
    @Update("update employer set name = #{name} where id = #{id}")
    int updateNameById(Integer id, String name);

    // 根据id修改用户的头像
    @Update("update employer set avatar_img = #{avatar} where id = #{id}")
    int updateAvatarById(Integer id, String avatar);

    //根据公司id查找招聘者id
    @Select("select id from employer where company_id=#{id}")
    int findByCompanyId(Integer id);

}
